package org.jivesoftware.smackx.pubsub;

import org.jivesoftware.smack.packet.PacketExtension;

public class PayloadItem<E extends PacketExtension> extends Item
{
  private E payload;

  public PayloadItem(String paramString, E paramE)
  {
    super(paramString);
    if (paramE == null)
      throw new IllegalArgumentException("payload cannot be 'null'");
    this.payload = paramE;
  }

  public E getPayload()
  {
    return this.payload;
  }

  public String toString()
  {
    return getClass().getName() + " | Content [" + toXML() + "]";
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder("<item");
    if (getId() != null)
    {
      localStringBuilder.append(" id='");
      localStringBuilder.append(getId());
      localStringBuilder.append("'");
    }
    localStringBuilder.append(">");
    localStringBuilder.append(this.payload.toXML());
    localStringBuilder.append("</item>");
    return localStringBuilder.toString();
  }
}